#
# @lc app=leetcode.cn id=781 lang=python3
#
# [781] 森林中的兔子
#

# @lc code=start
from typing import List
class Solution:
    def numRabbits(self, answers: List[int]) -> int:
        import collections
        store = collections.defaultdict(int)
        for ans in answers:
            store[ans]+=1
        ans = 0
        print(store)
        for k, v in store.items():
            add = (k+1)*(v//(k+1)+1) if v%(k+1) else v
            ans += add
        return ans
# @lc code=end

if __name__=='__main__':
    solution = Solution()
    anwsers = [1,0,1,0,0]
    print(solution.numRabbits(anwsers))
